package org.batyrov.equery.action.admin;

import org.batyrov.equery.action.BaseAction;
import org.batyrov.equery.action.Const;
import org.batyrov.equery.bean.User;
import org.batyrov.equery.bean.Window;
import org.batyrov.equery.bean.Service;

import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: admin
 * Date: 13.09.2009
 * Time: 18:52:22
 * To change this template use File | Settings | File Templates.
 */
public class GetService extends BaseAction{
    private Collection<Window> windows;
    private Service service;
    private long id = -1;

    public Collection<Window> getWindows() {
        return windows;
    }

    public void setWindows(Collection<Window> windows) {
        this.windows = windows;
    }

    public Service getService() {
        return service;
    }

    public void setService(Service service) {
        this.service = service;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Override
    public String execute() throws Exception {
        super.execute();
        service = em.find(Service.class, id);
        windows = dao.getAllWindow();
        if (service != null)
            windows.removeAll(service.getWindows());
        return Const.SUCCESS;
    }
}
